home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12899 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: solon.com!not-for-mail
  2. From: nsmart@indigo.ie (Niall Smart)
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated,hp.unix,comp.sys.hp.apps,comp.sys.hp.hpux
  4. Subject: Re: C coding problem
  5. Date: 3 Apr 1996 07:15:38 -0600
  6. Organization: None
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4jttlq$3p1@solutions.solon.com>
  10. References: <4ianbf$h86@solutions.solon.com> <4iemcl$a05@solutions.solon.com> <4io1io$no4@solutions.solon.com> <4j41ru$nq4@solutions.solon.com>
  11. NNTP-Posting-Host: solutions.solon.com
  12. X-Newsreader: Forte Free Agent 1.0.82
  13.  
  14. Michael Smith <msmith@mpx.com.au> wrote:
  15.  
  16. >Konrad Schwarz wrote:
  17. >> 
  18. >> I recently wrote a loop that went like this:
  19. >> 
  20. >> while (p < end_p)
  21. >>         ++*p++;
  22. >> 
  23.  
  24. >This is largely a matter of taste
  25.  
  26. I would argue that it is far more than that.
  27.  
  28. >, but personally I don't like that 
  29. >construct.  A programmer less skilled than you might easily misunderstand 
  30. >that and introduce an error.  I would prefer:
  31.  
  32. >for ( ; p<end_p; p++) 
  33. >    ++(*p);
  34.  
  35. or either of:
  36.  
  37. while (p < end_p)
  38. {
  39.     (*p)++;
  40.     p++;
  41. }
  42.  
  43. while (p++ < end_p)
  44. {
  45.     (*p)++;
  46. }
  47.  
  48. Zero chance for ambiguity in the last three versions.
  49.  
  50. Niall 
  51.